<?php
	//Income status
	$IncomeStatus="Pass";
	if($numberofdependant==0) $StandardLivingFee=990;	
	if($numberofdependant==1) $StandardLivingFee=1224;
	if($numberofdependant==2) $StandardLivingFee=1458;
	if($numberofdependant==3) $StandardLivingFee=1692;
	if($numberofdependant==4) $StandardLivingFee=1926;
	if($numberofdependant==5) $StandardLivingFee=2161;
	if($numberofdependant==6) $StandardLivingFee=2395;
	//Income
	if($incomeaftertax1period=="Weekly") $totalIncome=$incomeaftertax*52/12;
	if($incomeaftertax1period=="Fortnightly") $totalIncome=$incomeaftertax*26/12;
	if($incomeaftertax1period=="Monthly") $totalIncome=$incomeaftertax;
	//Loan repayment		
	if($loanrepaymentperiod=="Weekly") $expense1=$liabilitiesloanrepaymentpayment*52/12;
	if($loanrepaymentperiod=="Fortnightly") $expense1=$liabilitiesloanrepaymentpayment*26/12;
	if($loanrepaymentperiod=="Monthly") $expense1=$liabilitiesloanrepaymentpayment;
	//Credit Card repayment			
	if($creditcardpaymentperiod=="Weekly") $expense2=$liabilitiescreditcardpayment*52/12;
	if($creditcardpaymentperiod=="Fortnightly") $expense2=$liabilitiescreditcardpayment*26/12;
	if($creditcardpaymentperiod=="Monthly") $expense2=$liabilitiescreditcardpayment;
	//Boarding/Renting Fee
	if($boardingrentingperiod=="Weekly") $expense3=$liabilitiesboardingrentingfeepayment*52/12;
	if($boardingrentingperiod=="Fortnightly") $expense3=$liabilitiesboardingrentingfeepayment*26/12;
	if($boardingrentingperiod=="Monthly") $expense3=$liabilitiesboardingrentingfeepayment;
	//Living Expense	
	if($livingexpensesperiod=="Weekly") $expense4=$liabilitieslivingexpensespayment*52/12;
	if($livingexpensesperiod=="Fortnightly") $expense4=$liabilitieslivingexpensespayment*26/12;
	if($livingexpensesperiod=="Monthly") $expense4=$liabilitieslivingexpensespayment;	
	if($expense4<$StandardLivingFee) $expense4=$StandardLivingFee;
	//total income and disposable income
	$totalExpense=$expense1+$expense2+$expense3+$expense4;
	$di=$totalIncome-$totalExpense;

	if($totalIncome <= 2166) $IncomeStatus="Fail";	
	if($di<400)	$IncomeStatus="Fail";
	
	//Credit Status
	$CreditStatus="Pass";
	if($hardship=="Yes") $CreditStatus="Fail"; 
	if($Gambling=="Yes") $CreditStatus="Fail";
	if($loaninlasttwomonth=="Yes") $CreditStatus="Fail";
	if($credithistory!="Clean (no default)" && $credithistory!="1 default") $CreditStatus="Fail"; 
	if($credithistory=="1 default"){
				if($totaloutstanding>500) $CreditStatus="Fail";  
	}

	//Final status
		$finalstatusByDecision="Pass";
		if($CreditStatus=="Fail" || $IncomeStatus=="Fail") 
			$finalstatusByDecision="Fail";
		
	if($loanamount<600) $ela=$loanamount;
	if($loanamount>=600) $ela=600;			
/*	    echo "total income is".$totalIncome."<br>";
		echo "totalExpense is".$totalExpense."<br>";		
		echo "disposable income is".$di."<br>";	
		echo "Income Status is".$IncomeStatus."<br>";
		
		
		echo "credithistory is".$credithistory."<br>";
		echo "hardship is".$hardship."<br>";	
		echo "Gambling is".$Gambling."<br>";	
		echo "loaninlasttwomonth is".$loaninlasttwomonth."<br>";	
		echo "Credit Status is".$CreditStatus."<br>";
		
		echo "final status is".$finalstatusByDecision."<br>";	*/

?>